
com.solacesystems.jcsmp.SpringJCSMPFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solace-java-spring-boot-autoconfigure Show documentation
Show all versions of solace-java-spring-boot-autoconfigure Show documentation
AutoConfiguration for messaging using the Solace Java API
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.solacesystems.jcsmp;
/**
* Wrapper of JCSMP Singleton Factory to more easily work within Spring Auto Configuration environments.
*/
public class SpringJCSMPFactory {
protected JCSMPProperties jcsmpProperties;
public SpringJCSMPFactory(JCSMPProperties properties) {
this.jcsmpProperties = (JCSMPProperties)properties.clone();
}
/**
* Acquires a {@link JCSMPSession} implementation for the specified
* properties in the default Context
.
*
* @return A {@link JCSMPSession} implementation with the specified
* properties.
* @throws InvalidPropertiesException
* Thrown if the required properties are not provided, or if
* unsupported properties (and combinations) are detected.
*/
public JCSMPSession createSession() throws InvalidPropertiesException {
return JCSMPFactory.onlyInstance().createSession(jcsmpProperties);
}
/**
* Acquires a {@link JCSMPSession} and associates it to the given
* {@link Context}.
*
* @param context
* The Context
in which the new session will be
* created and associated with. If null
, the
* default context is used.
* @return A newly constructed session in context
.
* @throws InvalidPropertiesException
* on error
*/
public JCSMPSession createSession(Context context) throws InvalidPropertiesException {
return JCSMPFactory.onlyInstance().createSession(jcsmpProperties, context);
}
/**
* Acquires a {@link JCSMPSession} and associates it to the given
* {@link Context}.
*
* @param context
* The Context
in which the new session will be
* created and associated with. If null
, uses the
* default context.
* @param eventHandler
* A callback instance for handling session events.
* @return A newly constructed session in the context
Context.
* @throws InvalidPropertiesException
* on error
*/
public JCSMPSession createSession(
Context context,
SessionEventHandler eventHandler) throws InvalidPropertiesException {
return JCSMPFactory.onlyInstance().createSession(jcsmpProperties, context, eventHandler);
}
/* CONTEXT OPERATIONS */
/**
* Returns a reference to the default Context
. There is a
* single instance of a default context in the API.
*
* @return The default Context
instance.
*/
public Context getDefaultContext() {
return JCSMPFactory.onlyInstance().getDefaultContext();
}
/**
* Creates a new Context
with the provided properties.
*
* @param properties
* Configuration settings for the new Context
. If
* null
, the default configuration settings are used.
* @return Newly-created Context
instance.
*/
public Context createContext(ContextProperties properties) {
return JCSMPFactory.onlyInstance().createContext(properties);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy