try { connection = new Connection(); connection.Open(); // open the connection //work with the connection, DB CRUD operations } finally { if(connection != null) connection.Close(); // close the connection in finally block // so that even if the exception occurs, connection gets closed. }
var connectionInstance; // ... { WSConnection: function() { return connectionInstance || connectionInstance = new Connection(); }, // ... }
var someobj = (function() { var instance = null; return { WSConnection: function() { if (instance == null) { instance = new Connection(); } return instance; } }; })();
public class App extends Application { private static Connection connection; public Connection getConnectionInstance() { if (connection == null) connection = new Connection(); return connection; } }
public MppsSCU( ApplicationEntity ae) throws IOException { this.remote = new Connection(); this.ae = ae; }
var someobj = (function() { var instance = new Connection(); return { WSConnection: function() { return instance; } }; })();
var _instance = null; // you can also just create the singleton instance here (eager/non-lazy initialization) WSConnection: function() { if (!_instance) _instance = new Connection(); return _instance; }
WSConnection: function() { this.instance = this.instance || new Connection(); return this.instance; },
import com.xensource.xenapi.APIVersion; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Session; try{ Connectionn conn = new Connection(new URL(xenservIP)); Session.loginWithPassword(conn, xenservUsername,xenservPassword, APIVersion.latest().toString()); } catch(BadServerResponse | SessionAuthenticationFailed | XenAPIException | XmlRpcException | MalformedURLException) {// Your code}
ArrayList<Thread> connections = new ArrayList<Thread>(); while (true) { Thread c = new Thread(new Connection()); connections.add(c); c.start(); }
private FlowManager(Parcel in) { mConnection = new Connection(); mState = State.valueOf(in.readString()); mSplash = in.readParcelable(SplashScreen.class.getClassLoader()); mMenu = in.readParcelable(MainMenu.class.getClassLoader()); }
public Connection findConnection(String connDN) throws NamingException { String[] attrIds = { "dicomHostname", "dicomPort", "dicomTLSCipherSuite", "dicomInstalled" }; Attributes attrs = ctx.getAttributes(connDN, attrIds); Connection conn = new Connection(); loadFrom(conn, attrs, false); return conn; }
public StoreSCU(ApplicationEntity ae) throws IOException { this.remote = new Connection(); this.ae = ae; rq.addPresentationContext(new PresentationContext(1, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian)); }
private final Memo<Connection> conn = new Memo<Connection>( new Callable<Connection>() { public Connection call() throws Exception { return new Connection(); } }); public Connection getConnection() { return conn.get(); }
public Connection findConnection(String connDN) throws NamingException { String[] attrIds = { "dicomHostname", "dicomPort", "dicomTLSCipherSuite", "dicomInstalled" }; Attributes attrs = ctx.getAttributes(connDN, attrIds); Connection conn = new Connection(); loadFrom(conn, attrs, false); return conn; }
@SuppressWarnings("unused") public StoreSCU(ApplicationEntity ae) throws IOException { this.remote = new Connection(); this.ae = ae; rq.addPresentationContext(new PresentationContext(1, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian)); }
public StgCmtSCU(ApplicationEntity ae) throws IOException { this.remote = new Connection(); this.ae = ae; DicomServiceRegistry serviceRegistry = new DicomServiceRegistry(); serviceRegistry.addDicomService(new BasicCEchoSCP()); serviceRegistry.addDicomService(stgcmtResultHandler); ae.setDimseRQHandler(serviceRegistry); }
public StgCmtSCU(ApplicationEntity ae) throws IOException { this.remote = new Connection(); this.ae = ae; DicomServiceRegistry serviceRegistry = new DicomServiceRegistry(); serviceRegistry.addDicomService(new BasicCEchoSCP()); serviceRegistry.addDicomService(stgcmtResultHandler); ae.setDimseRQHandler(serviceRegistry); }
private void loadConnections(Device device, JsonReader reader) { reader.next(); reader.expect(JsonParser.Event.START_ARRAY); while (reader.next() == JsonParser.Event.START_OBJECT) { Connection conn = new Connection(); loadFrom(conn, reader); device.addConnection(conn); } reader.expect(JsonParser.Event.END_ARRAY); }
private void loadConnections(Device device, JsonReader reader) { reader.next(); reader.expect(JsonParser.Event.START_ARRAY); while (reader.next() == JsonParser.Event.START_OBJECT) { Connection conn = new Connection(); loadFrom(conn, reader); device.addConnection(conn); } reader.expect(JsonParser.Event.END_ARRAY); }